Skip to content

fix: add comprehensive tests for truncated JSON repair (#186)#213

Merged
ajianaz merged 1 commit into
developfrom
fix/186-repair-truncated-json
Jun 7, 2026
Merged

fix: add comprehensive tests for truncated JSON repair (#186)#213
ajianaz merged 1 commit into
developfrom
fix/186-repair-truncated-json

Conversation

@ajianaz

@ajianaz ajianaz commented Jun 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

The repair_truncated_json() function already existed and worked, but had zero test coverage. This adds 12 tests confirming correct behavior.

Changes

10 unit tests for repair_truncated_json:

  • Unclosed strings, arrays, objects
  • Nested structures with multiple unclosed brackets
  • Strings with escaped quotes (no false string-state detection)
  • Truncation after a complete first item (partial second item preserved)
  • Empty array edge case
  • Already-valid JSON passthrough

2 end-to-end integration tests:

  • parse_review_response with truncated JSON input
  • parse_scan_response with truncated JSON input

Verification

  • All 62 LLM module tests pass (was 50, now 62)
  • All 333+ total tests pass
  • Pre-commit hook: no issues found

Closes #186

- 10 new unit tests for repair_truncated_json covering:
  - Unclosed strings, arrays, objects
  - Nested structures with unclosed brackets
  - Strings with escaped quotes
  - Multiple unclosed brackets
  - Truncation after complete first item
  - Empty array edge case
  - Already-valid JSON passthrough
- 2 new end-to-end tests for parse_review_response and
  parse_scan_response with truncated input
- Confirms existing repair_truncated_json implementation works
  correctly — only lacked test coverage

Closes #186
@ajianaz
ajianaz merged commit ccba2c7 into develop Jun 7, 2026
11 checks passed
@ajianaz
ajianaz deleted the fix/186-repair-truncated-json branch June 8, 2026 04:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

enhancement: repair truncated JSON from LLM responses

1 participant